package com.example.awtDraw;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * @Author 郅占伟
 * @ClassName TestWindow
 * @Description TODO
 * @Date 2024年05月14日
 * @Version: 1.0
 */
public class TestWindow {
    public static void main(String[] args) {
        Frame frame = new Frame("验证码");
        Panel panel = new MyPanel();

        frame.add(panel);
        frame.setSize(500,450);

        // 将窗口居中
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {

                Window window = e.getWindow();
                window.setVisible(false);
                window.dispose();
            }
        });
    }
}
